<?php
namespace Admin\Model;

use Think\Model;

class UserModel extends Model{
    
     public function SelectInfo($map=array()){
          $page=$this->get_page($map);
          $result['page']=$page->show();
          $result['list']=$this->where($map)->limit($page->firstRow.','.$page->listRows)->select();
          return   $result;
     }
     
     public function getInfo($uid){
         $map['id']=$uid;
         $info=$this->where($map)->find();
         return  empty($info)? array():$info;
     }
     
     public function saveInfo($info){
         
         $map['id']=$info['id'];
         $data['note']=$info['note'];
         $data=$this->field('note')->create($data);
         $result=$this->where($map)->save();
         return $result>=0?true:false;
     }
     
     public function delete_member($info){
          
         $map['id']=$info['id'];
         $result=$this->where($map)->delete();
         return $result?true:false;
         
     }
     
     public function delete_all($info){
         $re= array();
         $re=explode('@',$info['ids']);
         if(!empty($re)){
         $map['id']=array('in',$re);
         $result=$this->where($map)->delete();
         return $result?true:false;
         }
         else{
          return false;   
         }
          
     }
     
     public function query_Info($note){
         $map['note']=array('like','%'.$note.'%');
         return $this->where($map)->select();
     }
     
     public function get_page($map,$table_q='User'){
          
         $count      = M($table_q)->where($map)->count();// 查询满足要求的总记录数
         $Page       = new \Think\Page($count,10);// 实例化分页类 传入总记录数和每页显示的记录数(1)
         $Page -> setConfig('prev','上一页');
         $Page -> setConfig('next','下一页');
         $Page->setConfig('theme', ' %FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER% ');
         return $Page;
          
     }
}
